#!/bin/sh

HP_WORKLOADS="0 60 65 70 72 74 76 78 80 81 82 83 84 85 86 87 88 89 90"
HP_MSGS=200
HP_CONSUMERS=1
HP_INTERVAL=25000

LP_WORKLOAD=500
LP_MSGS=50
LP_CONSUMERS=1
LP_INTERVAL=100000

/bin/rm -f NameService.ior NameService.pid EC1.pid EC2.pid EC.pid

# Generate the baseline data, i.e. shortcircuit the EC.

for w in $HP_WORKLOADS; do
  echo Local EC test $w
  ../../Naming_Service/Naming_Service \
    -o NameService.ior -p NameService.pid >/dev/null 2>&1 &
  sleep 2
  NameService=`cat NameService.ior`
  export NameService
  ./EC_Multiple -l ECM1 -s runtime -p ECM1.pid \
    -w 1,${LP_CONSUMERS},${LP_WORKLOAD},${LP_INTERVAL},${LP_MSGS},3,4,3,4 \
    -h 1,${HP_CONSUMERS},${w},${HP_INTERVAL},${HP_MSGS},1,2,1,2 > \
      UTL.LCL.${w}.log 2>&1

  kill `cat NameService.pid`

   ../../Naming_Service/Naming_Service \
        -o NameService.ior -p NameService.pid >/dev/null 2>&1 &
   sleep 2
   NameService=`cat NameService.ior`
   export NameService

  ./EC_Multiple -l ECM1 -r ECM2 -s runtime -p ECM1.pid \
    -w 1,${LP_CONSUMERS},${LP_WORKLOAD},${LP_INTERVAL},${LP_MSGS},1,2,1,3 \
    -h 1,${HP_CONSUMERS},${w},${HP_INTERVAL},${HP_MSGS},4,5,4,6 > \
      UTL.ECM1.${w}.log 2>&1 &
  ./EC_Multiple -l ECM2 -r ECM1 -s runtime -p ECM2.pid \
    -w 1,${LP_CONSUMERS},${LP_WORKLOAD},${LP_INTERVAL},${LP_MSGS},7,3,7,2 \
    -h 1,${HP_CONSUMERS},${w},${HP_INTERVAL},${HP_MSGS},8,6,8,5 > \
      UTL.ECM2.${w}.log 2>&1 &

    sleep 2
    wait `cat ECM1.pid`
    wait `cat ECM2.pid`
    kill `cat NameService.pid`

done

exit 0
